package com.example.module_visitor.viewmodel

import androidx.lifecycle.MutableLiveData
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.*
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class VisitorVIewModel @Inject constructor(
    val apiService: ApiService
):BaseViewModel() {
    //列表
    val visitorSuccess by lazy { MutableLiveData<VisitorEntity>() }
    fun getVisitor(){
        executeNetwork({
            apiService.getVisitor()
        },visitorSuccess::postValue)
    }
    //添加
    val addVisitorSuccess by lazy { MutableLiveData<AddAppointmentEntity>() }
    fun getAddVisitor(addAppointmentsBody: AddAppointmentsBody){
        executeNetwork({
            apiService.getAddAppointments(addAppointmentsBody)
        },addVisitorSuccess::postValue)
    }
    //删除
    val deleteVisitSuccess by lazy { MutableLiveData<String>() }
    fun getDeleteVisit(id:Int){
        executeNetwork({
            apiService.getDelete(id)
        },deleteVisitSuccess::postValue)
    }
    //驳回
    val rejectSuccess by lazy { MutableLiveData<RejectEntity>() }
    fun getReject(id:Int){
        executeNetwork({
            apiService.getReject(id)
        },rejectSuccess::postValue)
    }
    //审核
    val approveSuccess by lazy { MutableLiveData<RejectEntity>() }
    fun getApprove(id:Int){
        executeNetwork({
            apiService.getApprove(id)
        },rejectSuccess::postValue)
    }
}